package com.community.process._1010.common.utils.redis;

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.StringUtils;

public class RedisCondition implements Condition {
    @Override
    public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
        Integer port = context.getEnvironment().getProperty("spring.redis.port", Integer.class, 0);
        String host = context.getEnvironment().getProperty("spring.redis.host", String.class, "");
        return port != 0 && StringUtils.hasLength(host);
    }
}
